﻿ 
using TeachingEval.Sys.DAL;
using TeachingEval.Sys.IDAL;
using System;
using System.Data.Entity;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TeachingEval.Sys.DALFactory
{
    public partial class DbSession : IDbSession
    {
	
		private IclassaDal _classaDal;
        public IclassaDal classaDal
        {
            get
            {
                if(_classaDal == null)
                {
                    _classaDal = AbstractFactory.CreateclassaDal();
                }
                return _classaDal;
            }
            set { _classaDal = value; }
        }
	
		private IdeparcadreDal _deparcadreDal;
        public IdeparcadreDal deparcadreDal
        {
            get
            {
                if(_deparcadreDal == null)
                {
                    _deparcadreDal = AbstractFactory.CreatedeparcadreDal();
                }
                return _deparcadreDal;
            }
            set { _deparcadreDal = value; }
        }
	
		private IdepartmentDal _departmentDal;
        public IdepartmentDal departmentDal
        {
            get
            {
                if(_departmentDal == null)
                {
                    _departmentDal = AbstractFactory.CreatedepartmentDal();
                }
                return _departmentDal;
            }
            set { _departmentDal = value; }
        }
	
		private IevalcriteriaDal _evalcriteriaDal;
        public IevalcriteriaDal evalcriteriaDal
        {
            get
            {
                if(_evalcriteriaDal == null)
                {
                    _evalcriteriaDal = AbstractFactory.CreateevalcriteriaDal();
                }
                return _evalcriteriaDal;
            }
            set { _evalcriteriaDal = value; }
        }
	
		private IevalratingDal _evalratingDal;
        public IevalratingDal evalratingDal
        {
            get
            {
                if(_evalratingDal == null)
                {
                    _evalratingDal = AbstractFactory.CreateevalratingDal();
                }
                return _evalratingDal;
            }
            set { _evalratingDal = value; }
        }
	
		private IlessonDal _lessonDal;
        public IlessonDal lessonDal
        {
            get
            {
                if(_lessonDal == null)
                {
                    _lessonDal = AbstractFactory.CreatelessonDal();
                }
                return _lessonDal;
            }
            set { _lessonDal = value; }
        }
	
		private ImajorDal _majorDal;
        public ImajorDal majorDal
        {
            get
            {
                if(_majorDal == null)
                {
                    _majorDal = AbstractFactory.CreatemajorDal();
                }
                return _majorDal;
            }
            set { _majorDal = value; }
        }
	
		private IschcadreDal _schcadreDal;
        public IschcadreDal schcadreDal
        {
            get
            {
                if(_schcadreDal == null)
                {
                    _schcadreDal = AbstractFactory.CreateschcadreDal();
                }
                return _schcadreDal;
            }
            set { _schcadreDal = value; }
        }
	
		private IstucadreDal _stucadreDal;
        public IstucadreDal stucadreDal
        {
            get
            {
                if(_stucadreDal == null)
                {
                    _stucadreDal = AbstractFactory.CreatestucadreDal();
                }
                return _stucadreDal;
            }
            set { _stucadreDal = value; }
        }
	
		private IteacherDal _teacherDal;
        public IteacherDal teacherDal
        {
            get
            {
                if(_teacherDal == null)
                {
                    _teacherDal = AbstractFactory.CreateteacherDal();
                }
                return _teacherDal;
            }
            set { _teacherDal = value; }
        }

 // OAEntities Db = new OAEntities();
        public DbContext Db
        {
            get
            {
                return DbContextFactory.GetCurrentDbContext();
            }
        }

        /// <summary>
        /// 一个业务中经常涉及到对多张操作，我们希望链接一次数据库，完成对多张表数据的操作。提高性能。 工作单元模式。
        /// </summary>
        /// <returns></returns>
        public bool SaveChanges()
        {
            return Db.SaveChanges() > 0;
        }
	}	
}